//
//  MainViewController.swift
//  XMGG
//
//  Created by iDev on 6/25/17.
//  Copyright © 2017 iDev. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        NotificationCenter.default.addObserver(self, selector: #selector(exitLogin), name: NSNotification.Name(rawValue: "exitLogin"), object: nil)
        addChildViewControllers()
        
    }
    
    func addChildViewControllers() {
        addChildVC(vc: MainProjectViewController(), title: "所有项目", imgName: "toolbar_btnproject")
        addChildVC(vc: MainProjectViewController(), title: "成员", imgName: "toolbar_btnstaff")
        addChildVC(vc: MainProjectViewController(), title: "设置", imgName: "toolbar_btnset")
    }
    
    func addChildVC(vc: UIViewController, title:String, imgName:String){
//        tabBar.tintColor = UIColor.orange #4bb0ae
        tabBar.tintColor = UIColor(red: 39/255.0, green: 176/255.0, blue: 174/255.0, alpha: 1.0)
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imgName)
        
        let nav = UINavigationController(rootViewController: vc)
        let img = UIImage(named: "nav_bg")
//        img?.stretchableImage(withLeftCapWidth: Int(SCREENWIDTH/2.0), topCapHeight: Int(SCREENHEIGHT/2.0))
        nav.navigationBar.setBackgroundImage(img, for: .default)
        nav.navigationBar.shadowImage = UIImage()
        nav.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white, NSFontAttributeName:UIFont.init(name: "PingFang SC", size: 21)!]
        addChildViewController(nav)
    }

    func exitLogin(){
        navigationController?.popViewController(animated: true)
    }
}




